package com.wujing.scalatrait

object MixDemo {
  def main(args: Array[String]): Unit = {

    val mysql0 = new Mysql5 with Db5 with File5
    mysql0.insert(19)

    //报错
    //overriding method insert in trait File5 of type (int: Int)Unit;
    // method insert in trait Db5 of type (int: Int)Unit needs `abstract override' modifiers
    // val mysql = new Mysql5 with File5 with Db5
//    val mysql1 = new Mysql5 with File5 with Db5
//    mysql1.insert(100)
  }

}
trait Operate5{
  def insert(int: Int)
}


//如果我们在子特质中重写了父类的抽象方法，但是同时又调用了spuer
// 这时我们的方法不是完全实现，因此要声明 abstract override
//作用 这时我们的super.insert(id)的调用就和动态混入有密切的关系
trait File5 extends Operate5{

  abstract override def insert(int: Int): Unit = {
    println(int)
    super.insert(int)
  }
}

trait Db5 extends Operate5{

  override def insert(int: Int): Unit = {
    println(int)
  }
}
class Mysql5{}